package com.example.study.controller;

import com.example.study.pojo.User;
import com.example.study.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2023/10/8
 * @Version 1.0
 **/
@RestController
@RequestMapping("/user")
public class JsonController {
    @Resource
    private IUserService userService;
    @GetMapping("/users")
    public List<User> findAll(){
        return this.userService.findAll();
    }

    @GetMapping("/delete/{uid}")
    public boolean delete(@PathVariable int uid){
        return this.userService.del(uid);
    }

    @PostMapping("/save")
    public boolean save(User user){
        return this.userService.save(user);
    }

    @GetMapping("/find/{uid}")
    public User findById(@PathVariable int uid){
        return this.userService.findById(uid);
    }
}
